package org.dromara.admin.tenant.controller;

import lombok.RequiredArgsConstructor;
import org.dromara.admin.domain.bo.OrderBo;
import org.dromara.admin.service.IUserDetailService;
import org.dromara.common.core.domain.R;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.web.core.BaseController;
import org.dromara.lessor.domain.bo.HouseBo;
import org.dromara.lessor.service.IHouseService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 租户租房
 *
 * @author Lion Li
 * @date 2025-09-01
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/tenant")
public class TenantController extends BaseController {

    private final IHouseService houseService;

    /**
     * 用户租房
     */
    @PostMapping("/rentHouse")
    public R<Void> rentHouse(@RequestBody OrderBo bo) {
        Long userId = LoginHelper.getUserId();
        if (userId == null) {
            return R.fail("请先登录");
        }
        return toAjax(houseService.rentHouseByHouseId(bo, userId));
    }

}
